package cn.t222.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class DemoController {
    @Value("${api.server}")
    private String apiServer;
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/get")
    public Object get(Integer id) {
        return restTemplate.getForObject(apiServer + "/articles/" + id, Object.class, "");
    }
    @GetMapping("/get")
    public Object get2(Integer id) {

        ResponseEntity<Object> ret = restTemplate.getForEntity(apiServer + "/articles/" + id, Object.class, "");
        return ret;
    }
}
